package com.itheima.controller.cos;

import com.itheima.core.R;
import com.itheima.utils.CosClientUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;

@Slf4j
@RestController
@RequestMapping("/aliyun/oss")
public class OosController {

    /**
     * 图片上传
     * @param photoFile
     * @return
     */
    @PostMapping("/upload")
    private R upload(@RequestParam(value = "photoFile")MultipartFile photoFile){
        String uploadfile = CosClientUtils.uploadfile(photoFile);
        HashMap<String, String> map = new HashMap<>();
        map.put("url",uploadfile);
        return R.success("success",map);
    }


}
